const state = {
  AIVideoNode: {}, // node AI 视频监控
  VideoListNode: {}, // node 视频监控
  ProjectNode: {}, // node 项目监控
  projectBroadcastNode: {}, // 项目大屏 实时播报
  companyBroadcastNode: {
    laborAttendance: 0,
    keyAttendance: 0,
    towercraneInfo: 0,
    elevatorInfo: 0,
    videoCamerasInfo: 0,
    alarmInfo: 0
  } // 企业大屏 实时播报
}

const getters = {
  incomingAIVideoNode: state => {
    return state.AIVideoNode
  },
  incomingVideoListNode: state => {
    return state.VideoListNode
  },
  incomingProjectNode: state => {
    return state.ProjectNode
  },
  incomingProjectBroadcastNode: state => {
    return state.projectBroadcastNode
  },
  incomingCompanyBroadcastNode: state => {
    return state.companyBroadcastNode
  }
}

const mutations = {
  // node AI 视频监控
  setAIVideoNode (state, payload) {
    state.AIVideoNode = payload
  },
  // node video 视频监控
  setVideoListNode (state, payload) {
    state.VideoListNode = payload
  },
  // node project 视频监控
  setProjectNode (state, payload) {
    state.ProjectNode = payload
  },
  // 设置项目大屏 实时播报
  setProjectBroadcastNode (state, payload) {
    state.projectBroadcastNode = payload
  },
  // 设置企业大屏 实时播报
  setCompanyBroadcastNode (state, payload) {
    if (payload.itype === 7111) {   // 进场劳务人员
      state.companyBroadcastNode.laborAttendance = payload.value
    } else if (payload.itype === 7112) {   // 进场管理人员
      state.companyBroadcastNode.keyAttendance = payload.value
    } else if (payload.itype === 7113) {   // 在线塔吊
      state.companyBroadcastNode.towercraneInfo = payload.value
    } else if (payload.itype === 7114) {   // 在线升降机
      state.companyBroadcastNode.elevatorInfo = payload.value
    } else if (payload.itype === 7115) {   // 在线视屏监控探头
      state.companyBroadcastNode.videoCamerasInfo = payload.value
    } else if (payload.itype === 7116) {   // 预警报警数
      state.companyBroadcastNode.alarmInfo = payload.value
    }
  }
}

export default {
  state,
  getters,
  mutations
}
